
/*
 * Step1HadoopMapper.java
 *
 * Created on May 8, 2012, 11:14:14 PM
 */

package Step1;


import java.io.IOException;
// import org.apache.commons.logging.Log;
// import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.LongWritable;

import BasicTypes.Constants;
import BasicTypes.Position;

/**
 *
 * @author crazymooner
 */
public class Step1HadoopMapper extends MapReduceBase implements Mapper<Text,Text,IntWritable,Text> {
    // The Karmasphere Studio Workflow Log displays logging from Apache Commons Logging, for example:
    // private static final Log LOG = LogFactory.getLog("Step1.Step1HadoopMapper");

	
	
    @Override
    public void map(Text key, Text value, OutputCollector<IntWritable, Text> output, Reporter reporter)
            throws IOException {
    	int k = Integer.parseInt(key.toString());
    	int v = Integer.parseInt(value.toString());
    	Position kP = new Position(k);
    	//Position kV = new Position(v);
    	int group = kP.x/Constants.COLUMESIZE;
    	String str= key.toString() + " " + value.toString() + " ";
    	output.collect(new IntWritable(group), new Text(str));
    }
}
